<?php 
/*###########################################################################
 #
 #        Zhejiang Job Educational Technology Company
 #
 ###########################################################################
 #
 #  Filename: index_controller.php
 #
 #  Description:
 #
 #
 ###########################################################################
 #
 #    R E V I S I O N   L O G
 #
 #    Date       Name            Description
 #    --------   --------------- -------------------------------
 #    2011/7/25   zheng kai         Created.
 #
 ###########################################################################
 */

/**
 * Controller_Index 控制器
 */
class Controller_Index extends Controller_Abstract
{
	private $cat2nav = array('');//导航和信息类型编号的对应
	function __construct($app){
		parent::__construct($app);
		/*
		//所有栏目的信息
		$array_cat = array();
		$allCatData =  Newstype::find('isdelete = 0')->getAll()->toArray();
		foreach($allCatData as $k => $v){
			switch($v['type_flag']){
				case '1':
					$href = url('index/news',array('catId'=>$v['id']));
				break;
				case '2':
					$href = url('index/cate',array('catId'=>$v['id']));
				break;
				case '3':
					$href = 'javascript:void(0);';
				break;
				case '4':
					$href = url('index/news',array('catId'=>$v['id']));
				break;
				case '5':
					$href = 'javascript:void(0);';
				break;
				case '6':
					$href = url('index/classnews',array('catId'=>$v['id']));
				break;
			}
			if(!empty($v['the_url'])){
				$href = $v['the_url'];
			}
			$array_cat[$v['id']]['href'] = $href;
			$array_cat[$v['id']]['type_name'] = $v['type_name'];
			if ($v['nav'] == 1) {
				if (!empty($v['the_url'])) {
					$href = substr($this->_context->baseDir(), 0, -1).$v['the_url'];
				}
				$navigate[$k] = array('class'=>'','this_href'=>$href,'this_name'=>$v['type_name']);
				//$cat2nav[$v['id']] = 0;
			}
		}
		$this->_view['array_cat'] = $array_cat;
		//导航
		$this->_view['navigate'] = $navigate;
		// $this->_view['navigate'] = array(
		// 	0 => array('class'=>'','this_href'=>url('index/notice'),'this_name'=>'公 告'),
		// 	1 => array('class'=>'','this_href'=>url('index/news',array('catId'=>2)),'this_name'=>'新生必读'),
		// 	2 => array('class'=>'','this_href'=>url('index/course'),'this_name'=>'课程中心'),
		// 	3 => array('class'=>'','this_href'=>url('index/news',array('catId'=>7)),'this_name'=>'资讯中心'),
		// 	4 => array('class'=>'','this_href'=>url('index/news',array('catId'=>15)),'this_name'=>'招生指南'),
		// 	5 => array('class'=>'','this_href'=>url('index/news',array('catId'=>24)),'this_name'=>'帮 助'),
		// );
		//重要公告
		$notice_list_recommend = News::find('type_id=1 and recommend_flag = 1 and isdelete=0')->order('release_date desc,id desc')->top(6)->asArray()->getAll();
		$this->_view['notice_list_recommend'] = $notice_list_recommend;
		//热点公告
		$notice_list_hot = News::find('type_id=1 and isdelete=0')->order('hits desc')->top(6)->asArray()->getAll();
		$this->_view['notice_list_hot'] = $notice_list_hot;
		//重要课程
		$course_list_recommend = News::find('(type_id=36 or type_id=37 or type_id=38) and recommend_flag = 1 and isdelete=0')->order('release_date desc,id desc')->top(8)->asArray()->getAll();
		$this->_view['course_list_recommend'] = $course_list_recommend;
		//热点课程
		$course_list_hot = News::find('(type_id=36 or type_id=37 or type_id=38) and isdelete=0')->order('hits desc')->top(8)->asArray()->getAll();
		$this->_view['course_list_hot'] = $course_list_hot;
		//公告栏
		$news_list_1 = Newstype::find('id=1 and isdelete=0')->asArray()->getOne();
		$this->_view['news_list_1'] = $news_list_1['content'];
		*/

	}
	function actionIndex() {
		/*
		//导航
		$this->_view['indexclass'] = ' menuon';
		//最新动态
		$news_list_13 = News::find('type_id=5 and isdelete=0 and home_flag=1')->order('release_date desc,id desc')->top(7)->asArray()->getAll();
		$this->_view['news_list_13'] = $news_list_13;
		//考试信息
		$news_list_14 = News::find('type_id=14 and isdelete=0 and home_flag=1')->order('release_date desc,id desc')->top(7)->asArray()->getAll();
		$this->_view['news_list_14'] = $news_list_14;
		//浙江简报
		$news_list_16 = News::find('type_id=16 and isdelete=0 and home_flag=1')->order('release_date desc,id desc')->top(7)->asArray()->getAll();
		$this->_view['news_list_16'] = $news_list_16;
		//中心简报
		$news_list_17 = News::find('type_id=2 and isdelete=0 and home_flag=1')->order('release_date desc,id desc')->top(7)->asArray()->getAll();
		$this->_view['news_list_17'] = $news_list_17;
		//专题回顾
		//带图片新闻
		$news_list_17_1 = News::find('type_id=17 and isdelete=0 and home_flag=1 and top_flag=1 and content like "%img%"')->order('release_date desc,id desc')->asArray()->getOne();
		preg_match_all("/src=\"([^^]*?)\"/",stripslashes($news_list_17_1['content']),$ereg); 
		$img = @$ereg[0][0];//src="";
		$this->_view['img'] = $img;
		//列表
		$news_list_17_2 = News::find('type_id=17 and isdelete=0 and home_flag=1 and top_flag=0')->order('release_date desc,id desc')->top(4)->asArray()->getAll();
		$this->_view['news_list_17_1'] = $news_list_17_1;
		$this->_view['news_list_17_2'] = $news_list_17_2;
		//政策法规
		$news_list_18 = News::find('type_id=3 and isdelete=0 and home_flag=1')->order('release_date desc,id desc')->top(9)->asArray()->getAll();;
		$this->_view['news_list_18'] = $news_list_18;
		//高技能人才培训
		$this->_view['news_list_19'] = News::find('type_id=18 and isdelete=0 and home_flag=1')->order('release_date desc,id desc')->top(9)->asArray()->getAll();
		//技术培训
		$this->_view['news_list_20'] = News::find('type_id=19 and isdelete=0 and home_flag=1')->order('release_date desc,id desc')->top(4)->asArray()->getAll();
		//业务指南
		$this->_view['news_list_21'] = News::find('type_id=21 and isdelete=0 and home_flag=1')->order('release_date desc,id desc')->top(4)->asArray()->getAll();
		//鉴定工种
		$this->_view['news_list_22'] = News::find('type_id=4 and isdelete=0 and home_flag=1')->order('release_date desc,id desc')->top(8)->asArray()->getAll();
		//资讯中心--自考常识
		$this->_view['news_list_11'] = News::find('type_id=11 and isdelete=0 and home_flag=1')->order('release_date desc,id desc')->top(3)->asArray()->getAll();
		//友情链接
		$links = Links::find('pic is not null')->order('taxis desc,id desc')->top(8)->asArray()->getAll();
		$this->_view['links1'] = array_slice($links, 0, 4);
		$this->_view['links2'] = array_slice($links, 4, 4);
		//广告位
		$this->_view['pic'] = Banner::find('type_id=1')->order('banner_id desc')->top(4)->asArray()->getAll();
		//长条广告
		$this->_view['longpic'] = Banner::find('type_id=2')->order('banner_id desc')->top(1)->asArray()->getAll();
		//切换广告
		$this->_view['changepic'] = Banner::find('type_id=3')->order('banner_id desc')->top(4)->asArray()->getAll();
		*/
		//首页幻灯
		$this->_view['pic'] = Banner::find('type_id=1')->order('banner_id desc')->top(7)->asArray()->getAll();
		//凯欧观点
		$this->_view['news_list_1'] = News::find('type_id=56 and isdelete=0 and home_flag=1')->order('release_date desc,id desc')->top(4)->asArray()->getAll();
		//新闻动态
		$this->_view['news_list_2'] = News::find('type_id=57 and isdelete=0 and home_flag=1')->order('release_date desc,id desc')->top(5)->asArray()->getAll();
		//活动节目
		$this->_view['news_list_3'] = News::find('type_id=58 and isdelete=0 and home_flag=1')->order('release_date desc,id desc')->top(8)->asArray()->getAll();
		//活动节目滚动图片
		$this->_view['news_list_4'] = News::find('type_id=58 and isdelete=0 and pic is not null')->order('release_date desc,id desc')->top(8)->asArray()->getAll();
		//个性礼品滚动图片
		$this->_view['news_list_5'] = News::find('type_id=6 and isdelete=0 and pic is not null')->order('release_date desc,id desc')->top(8)->asArray()->getAll();
	}
	function actionP30() {
		$lists = Newstype::find('pid=52 and isdelete=0')->order('taxis desc,id desc')->asArray()->getAll();
		$this->_view['lists'] = $lists;
	}
	function actionEp() {}
	function actionCp() {}
	function actionPindex(){}
	function actionProduct() {
		//左侧分类
		$lists = Newstype::find('pid=5 and isdelete=0')->order('taxis desc,id desc')->asArray()->getAll();
		$this->_view['lists'] = $lists;

	}
	function actionContactus() {}
	function actionNecklace() {}
	function actionNeckread() {}
	//公告列表
	function actionNotice() {
		$user = $this->_app->currentUser();
		$this->_view['user'] = $user;
		$catId = 1;
		//导航
		$this->_view['navigate'][0]['class'] = ' menuon';
		//nav
		$newstype = new Newstype();
		$rootid = $newstype->get_rootid($catId);
		$this->_view['location'] = $newstype->get_location();
		//分页
        $page = (int)$this->_context->page;
		if ($page==0) $page++;
		$limit = 20;
		$list = News::find('type_id=? and isdelete=0', $catId)->order('release_date desc,id desc')->limitPage($page, $limit);
		$this->_view['pager'] = $list->getPagination();
		$this->_view['list'] = $list->getAll();
		$this->_view['start'] = ($page-1)*$limit;
		$this->_view['rootid'] = $rootid;
		$this->_view['catId'] = $catId;
	}
	//公告详细页
	function actionNoticeread() {
		$user = $this->_app->currentUser();
		$this->_view['user'] = $user;
		$newsid = $this->_context->newsid;
		$news = News::find()->getById($newsid);
		$catId = $news->type_id;
		$news->hits++;
		$news->save();
		//导航
		$this->_view['navigate'][0]['class'] = ' menuon';
		//nav
		$newstype = new Newstype();
		$rootid = $newstype->get_rootid($catId);
		$this->_view['location'] = $newstype->get_location();
		$this->_view['news'] = $news;
		$this->_view['rootid'] = $rootid;
		$enclosure = Enclosure::find('pid=?', $newsid)->getAll()->toArray();
        if(!empty($enclosure)){
            $this->_view['enclosure'] = $enclosure;
		}
		//上一篇
		$proData = News::find("isdelete=0 and id < '$newsid'")->order('release_date desc,id desc')->getOne()->toArray();
		$this->_view['proData'] = $proData;
		//下一篇
		$nextData = News::find("isdelete=0 and id > '$newsid'")->order('id asc')->getOne()->toArray();
		$this->_view['nextData'] = $nextData;
	}
	function actionNews() {
		$user = $this->_app->currentUser();
		$this->_view['user'] = $user;
		$catId = $this->_context->catId;
		$where = "isdelete=0";
		//nav
		$newstype = new Newstype();
		$rootid = $newstype->get_rootid($catId);
		//dump($rootid);dump($this->cat2nav);die;
		//导航
		// if(array_key_exists($rootid,$this->cat2nav)){
		// 	$this->_view['navigate'][$this->cat2nav[$rootid]]['class'] = ' menuon';
		// }
		$roots = Newstype::find()->getById($rootid);
		$this->_view['roots'] = $roots;
		$this->_view['navigate'][$rootid-1]['class'] = ' menuon';
		$this->_view['location'] = $newstype->get_location();
		//左侧栏目
		$menu_list = $newstype -> find("isdelete=0 and pid='$rootid'")->order('taxis desc')->getAll()->toArray();
	    $this->_view['menu_list'] = $menu_list;	
		//查询条件，得到该类下所有的子类id
		$ids = $newstype -> get_ids($catId);
		//print_r($ids);
		if(!empty($ids)){
			$where .= " and type_id in (".implode(',',$ids).")";;
		}
		//分页
        $page = (int)$this->_context->page;
		if ($page==0) $page++;
		$limit = 20;
		$list = News::find($where)->order('release_date desc,id desc')->limitPage($page, $limit);
		$this->_view['pager'] = $list->getPagination();
		$this->_view['list'] = $list->getAll();
		$this->_view['start'] = ($page-1)*$limit;
		$this->_view['rootid'] = $rootid;
		$this->_view['catId'] = $catId;
	}

	function actionNewsread() {
		$newsid = $this->_context->newsid;
		$news = News::find()->getById($newsid);
		$catId = $news->type_id;
		$news->hits++;
		$news->save();
		//nav
		$newstype = new Newstype();
		$rootid = $newstype->get_rootid($catId);
		//导航
		$this->_view['navigate'][$rootid-1]['class'] = ' menuon';
		//左侧栏目
		$menu_list = $newstype -> find("isdelete=0 and pid='$rootid'")->order('taxis desc')->getAll()->toArray();
	    $this->_view['menu_list'] = $menu_list;
		$this->_view['location'] = $newstype->get_location();
		$this->_view['news'] = $news;
		$this->_view['rootid'] = $rootid;
		$enclosure = Enclosure::find('pid=?', $newsid)->getAll()->toArray();
        if(!empty($enclosure)){
            $this->_view['enclosure'] = $enclosure;
		}
		//上一篇
		$proData = News::find("isdelete=0 and id < '$newsid'")->order('release_date desc,id desc')->getOne()->toArray();
		$this->_view['proData'] = $proData;
		//下一篇
		$nextData = News::find("isdelete=0 and id > '$newsid'")->order('id asc')->getOne()->toArray();
		$this->_view['nextData'] = $nextData;
	}
	//类新闻
	function actionClassnews(){
		$user = $this->_app->currentUser();
		$this->_view['user'] = $user;
		$catId = $this->_context->catId;
		$where = "isdelete=0";
		//nav
		$newstype = new Newstype();
		$rootid = $newstype->get_rootid($catId);
		$cat = $newstype->find()->getById($catId);
		//导航
		$this->_view['navigate'][$rootid-1]['class'] = ' menuon';
		$this->_view['location'] = $newstype->get_location();
		//左侧栏目
		$menu_list = $newstype -> find("isdelete=0 and pid='$rootid'")->order('taxis desc')->getAll()->toArray();
	    $this->_view['menu_list'] = $menu_list;
	    $left = '';
	    foreach ($menu_list as $key => $value) {
	    	$menu_list_son = '';
	    	$class = false;
	    	//获得子菜单
	    	$menu_list_son = $newstype -> find("isdelete=0 and pid=?",$value['id'])->order('taxis desc')->getAll()->toArray();
	    	//拼接左侧菜单
	    	if($cat['pid'] == $value['id'] or $catId == $value['id']){
	    		$left .= '<dt id="'.$value['id'].'"><a href="'.url('index/classnews', array('catId'=>$value['id'])).'">'.$value['type_name'].'</a></dt>';
	    		$class = true;
	    	}else{
	    		$left .= '<dt class="open" id="'.$value['id'].'"><a href="'.url('index/classnews', array('catId'=>$value['id'])).'">'.$value['type_name'].'</a></dt>';
	    	}
	    	foreach ($menu_list_son as $k => $v) {
	    		if($v['pid'] == $value['id']){
	    			if ($catId == $v['id']) {
	    				$left .= '<dd class="on son_'.$v['pid'].'"><a href="'.url('index/classnews', array('catId'=>$v['id'])).'">'.$v['type_name'].'</a></dd>';
	    			}elseif (!$class) {
	    				$left .= '<dd class="son_'.$v['pid'].'" style="display: none;"><a href="'.url('index/classnews', array('catId'=>$v['id'])).'">'.$v['type_name'].'</a></dd>';
	    			}else{
	    				$left .= '<dd class="son_'.$v['pid'].'"><a href="'.url('index/classnews', array('catId'=>$v['id'])).'">'.$v['type_name'].'</a></dd>';
	    			}
	    		}
	    	}
	    }
	 	$this->_view['left'] = $left;

		//查询条件，得到该类下所有的子类id
		$ids = $newstype -> get_ids($catId);
		//print_r($ids);
		if(!empty($ids)){
			$where .= " and type_id in (".implode(',',$ids).")";;
		}
		//分页
        $page = (int)$this->_context->page;
		if ($page==0) $page++;
		$limit = 20;
		$list = News::find($where)->order('release_date desc,id desc')->limitPage($page, $limit);
		$this->_view['pager'] = $list->getPagination();
		$this->_view['list'] = $list->getAll();
		$this->_view['start'] = ($page-1)*$limit;
		$this->_view['rootid'] = $rootid;
		$this->_view['catId'] = $catId;
	}

	function actionClassnewsread(){
		$user = $this->_app->currentUser();
		$this->_view['user'] = $user;
		$newsid = $this->_context->newsid;
		$news = News::find()->getById($newsid);
		$news->hits++;
		$news->save();
		$catId = $news->type_id;
		$where = "isdelete=0";
		//nav
		$newstype = new Newstype();
		$rootid = $newstype->get_rootid($catId);
		$cat = $newstype->find()->getById($catId);
		//导航
		$this->_view['navigate'][$rootid-1]['class'] = ' menuon';
		$this->_view['location'] = $newstype->get_location();
		//左侧栏目
		$menu_list = $newstype -> find("isdelete=0 and pid='$rootid'")->order('taxis desc')->getAll()->toArray();
	    $this->_view['menu_list'] = $menu_list;
	    $left = '';
	    foreach ($menu_list as $key => $value) {
	    	$menu_list_son = '';
	    	$class = false;
	    	//获得子菜单
	    	$menu_list_son = $newstype -> find("isdelete=0 and pid=?",$value['id'])->order('taxis desc')->getAll()->toArray();
	    	//拼接左侧菜单
	    	if($cat['pid'] == $value['id'] or $catId == $value['id']){
	    		$left .= '<dt id="'.$value['id'].'"><a href="'.url('index/classnews', array('catId'=>$value['id'])).'">'.$value['type_name'].'</a></dt>';
	    		$class = true;
	    	}else{
	    		$left .= '<dt class="open" id="'.$value['id'].'"><a href="'.url('index/classnews', array('catId'=>$value['id'])).'">'.$value['type_name'].'</a></dt>';
	    	}
	    	foreach ($menu_list_son as $k => $v) {
	    		if($v['pid'] == $value['id']){
	    			if ($catId == $v['id']) {
	    				$left .= '<dd class="on son_'.$v['pid'].'"><a href="'.url('index/classnews', array('catId'=>$v['id'])).'">'.$v['type_name'].'</a></dd>';
	    			}elseif (!$class) {
	    				$left .= '<dd class="son_'.$v['pid'].'" style="display: none;"><a href="'.url('index/classnews', array('catId'=>$v['id'])).'">'.$v['type_name'].'</a></dd>';
	    			}else{
	    				$left .= '<dd class="son_'.$v['pid'].'"><a href="'.url('index/classnews', array('catId'=>$v['id'])).'">'.$v['type_name'].'</a></dd>';
	    			}
	    		}
	    	}
	    }
	 	$this->_view['left'] = $left;
	 	//内容
		$this->_view['news'] = $news;
	}


	function actionCate() {
		$user = $this->_app->currentUser();
		$this->_view['user'] = $user;
		$catId = $this->_context->catId;
		//nav
		$newstype = Newstype::find()->getById($catId);
		$rootid = $newstype->get_rootid($catId);
		//导航
		// if(array_key_exists($rootid,$this->cat2nav)){
		// 	$this->_view['navigate'][$this->cat2nav[$rootid]]['class'] = ' menuon';
		// }
		$menu_list_pid = '';
		$menu_list_title = array();
		$this->_view['navigate'][$rootid-1]['class'] = ' menuon';
		//右侧栏目
		$menu_list = $newstype -> find("isdelete=0 and type_name like '%公告%' and type_name!='公告栏'")->order('taxis desc')->getAll()->toArray();
		foreach ($menu_list as $key => $value) {
			$arr_temp = News::find("isdelete=0 and type_id=?", $value['id'])->order('release_date desc')->setcolumns('id,type_id,title,release_date')->limit(0,5)->getAll()->toArray();
			$menu_list_title = array_merge($menu_list_title, $arr_temp);
		}
	    //$menu_list_pid_str = implode(',', $menu_list_pid);
	    //$menu_list_title = News::find("isdelete=0 and type_id in ($menu_list_pid_str)")->order('release_date desc')->setcolumns('id,type_id,title,release_date')->getAll()->toArray();
	    $this->_view['menu_list'] = $menu_list;
		$this->_view['location'] = $newstype->get_location();
		$this->_view['newstype'] = $newstype;
		$this->_view['rootid'] = $rootid;
		$this->_view['menu_list_title'] = $menu_list_title;
	}

	function actionSearch() {
		$user = $this->_app->currentUser();
		$this->_view['user'] = $user;
		$keyword = $this->_context->keyword;
		//nav
		//分页
        $page = (int)$this->_context->page;
		if ($page==0) $page++;
		$limit = 20;
		$s_keyword = '%'.s($keyword).'%';
		$list = News::find('(title like ? or content like ?) and isdelete=0', $s_keyword, $s_keyword)->order('release_date desc,id desc')->limitPage($page, $limit);
		$this->_view['pager'] = $list->getPagination();
		$this->_view['list'] = $list->getAll();
		$this->_view['start'] = ($page-1)*$limit;
		$this->_view['rootid'] = 0;
	}

	function actionCourse() {
		$user = $this->_app->currentUser();
		$this->_view['user'] = $user;
		$catId = $this->_context->catId;
		$newstype = Newstype::find()->getById($catId);
		$rootid = $newstype->get_rootid($catId);
		//导航
		$this->_view['navigate'][$rootid-1]['class'] = ' menuon';
		//分页
        $page = (int)$this->_context->page;
		if ($page==0) $page++;
		$catId = intval($this->_context->catId);
		$page_36 = $page_37 = $page_38 = 0;
		if(empty($catId)){
			$catId = 36;
		}else{
			switch($catId){
			case 36:
				$page_36 = $page;
				break;
			case 37:
				$page_37 = $page;
				break;
			case 38:
				$page_38 = $page;
				break;
			}
		}
		$limit = 6;
		$list_36 = News::find("isdelete=0 and type_id='36'")->order('release_date desc,id desc')->limitPage($page_36, $limit);
		$this->_view['pager_36'] = $list_36->getPagination();
		$this->_view['list_36'] = $list_36->getAll();

		$list_37 = News::find("isdelete=0 and type_id='37'")->order('release_date desc,id desc')->limitPage($page_37, $limit);
		$this->_view['pager_37'] = $list_37->getPagination();
		$this->_view['list_37'] = $list_37->getAll();

		$list_38 = News::find("isdelete=0 and type_id='38'")->order('release_date desc,id desc')->limitPage($page_38, $limit);
		$this->_view['pager_38'] = $list_38->getPagination();
		$this->_view['list_38'] = $list_38->getAll();
		//$this->_view['start'] = ($page-1)*$limit;
		$this->_view['catId'] = $catId;
	}
	//课程详细页
	function actionCourseread() {
		$newsid = $this->_context->newsid;
		$news = News::find()->getById($newsid);
		$news->hits++;
		$news->save();
		//nav
		$newstype = new Newstype();
		//导航
		$this->_view['navigate'][2]['class'] = ' menuon';
		$this->_view['news'] = $news;
		$enclosure = Enclosure::find('pid=?', $newsid)->getAll()->toArray();
        if(!empty($enclosure)){
            $this->_view['enclosure'] = $enclosure;
		}
	}
	//留言板
	function actionGuestbook(){
		$where ='show_flag = 1';
        @$keyword = empty($_POST['keyword'])?'':' and question like "%'.$_POST['keyword'].'%"';
        
        $where .= $keyword;
        $page = (int)$this->_context->page;
        if($page==0) $page++;
        $limit = $this->_context->limit ? $this->_context->limit:15;
        $q = Message::find($where)->order('id desc')->limitPage($page, $limit);
        $this->_view['pager'] = $q->getPagination();
        $this->_view['list'] = $q->getAll();
        $this->_view['start'] = ($page-1)*$limit;
        $this->_view['keyword'] = @$_POST['keyword'];
	}
	//在线留言
	function actionAsk(){
        //echo $userip;
        @$imgcode = $_POST['imgcode'];
	    if($this->_context->isPOST() && $imgcode == $_SESSION['askCode'])
        {
            if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
		    //如果变量是非空或非零的值，则 empty()返回 FALSE。
			    $ip = explode(',',$_SERVER['HTTP_CLIENT_IP']);
		    }
		    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
			    $ip = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
		    }
		    elseif (!empty($_SERVER['REMOTE_ADDR'])) {
			    $ip = explode(',',$_SERVER['REMOTE_ADDR']);
		    }
		    else {
			    $ip[0] = 'None';
		    }

            @$name = $_POST['username'];
            @$email = $_POST['email'];
            @$mobile = $_POST['mobile'];
            @$content = strip_tags($_POST['content']);
            
            $userip = $ip[0];

            $addtime = time();
            $sql = "INSERT INTO tt_message (asker, ip, email, tel, question, q_time) VALUES ('".$name."', '".$userip."', '".$email."', '".$mobile."', '".$content."', '".$addtime."') ";
            //echo $sql;
            $db = QDB::getConn();
            $db->execute($sql);

            $this->_view['success'] = 'T';
        }elseif($this->_context->isPOST() && $imgcode != $_SESSION['askCode'])
        {
            $this->_view['code'] = 'F';
            $this->_view['username'] = @$_POST['username'];
            $this->_view['email'] = @$_POST['email'];
            $this->_view['mobile'] = @$_POST['mobile'];
            $this->_view['content'] = @$_POST['content'];
            $this->_view['imgcode'] = @$_POST['imgcode'];
        }
	}
		//验证码
	function actionImagecode(){
		$code = Helper_Util::str_random();
		$_SESSION['askCode'] = $code;
		$config = array('vCode' => $code); 
		//$imagecode = new Helper_Imagecode($config);
		//$imagecode->getImageCode();
		$font_dir = Q::ini('app_config/ROOT_DIR').DIRECTORY_SEPARATOR.'index_css'.DIRECTORY_SEPARATOR;
		$captcha = new Helper_Captcha(array('resourcesPath' => $font_dir,'text' => $code,'width' => 130,'backgroundColor' => array(237,247,255),'height' => 50,'fonts' => array( 'Times' => array('spacing' => -2, 'minSize' => 14, 'maxSize' => 20, 'font' => 'TimesNewRomanBold.ttf'))));
		$captcha -> CreateImage();
	}
	function actionPlatform(){
		
	}
}
